#
# Copyright 2021 The Modelbox Project Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


cmake_minimum_required(VERSION 3.10)

set(UNIT_GRAPHCONF "graphconf")
set(UNIT_NAME "mockgraphconf")

project(modelbox-${UNIT_NAME}-${UNIT_GRAPHCONF})

file(GLOB_RECURSE LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SOURCES *.cpp *.cc *.c)
set(LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_INCLUDE ${CMAKE_CURRENT_LIST_DIR})

include_directories(${CMAKE_CURRENT_LIST_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${LIBMODELBOX_INCLUDE})
include_directories(${LIBMODELBOX_BASE_INCLUDE})
include_directories(${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_INCLUDE})

set(LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_INCLUDE ${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_INCLUDE} ${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_INCLUDE})
set(LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED mock_graphconf)

add_library(${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED} SHARED ${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SOURCES})

set_target_properties(${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED} PROPERTIES 
    SOVERSION ${MODELBOX_VERSION_MAJOR}
    VERSION ${MODELBOX_VERSION_MAJOR}.${MODELBOX_VERSION_MINOR}.${MODELBOX_VERSION_PATCH}
)

target_link_libraries(${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED} pthread)
target_link_libraries(${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED} rt)
target_link_libraries(${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED} dl)
target_link_libraries(${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED} ${LIBMODELBOX_GRAPHCONF_GRAPHVIZ_SHARED})
target_link_libraries(${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED} ${LIBMODELBOX_SHARED})

set_target_properties(${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED} PROPERTIES OUTPUT_NAME "modelbox-${UNIT_GRAPHCONF}-${UNIT_NAME}")

install(TARGETS ${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED}
        RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
        LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
        ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
        OPTIONAL)
install(DIRECTORY ${HEADER} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR})

set(LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED ${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SHARED} CACHE INTERNAL "")
set(LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_INCLUDE ${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_INCLUDE} CACHE INTERNAL "")
set(LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SOURCES ${LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SOURCES} CACHE INTERNAL "")
set(LIBMODELBOX_GRAPHCONF_MOCKGRAPHCONF_SO ${CMAKE_CURRENT_BINARY_DIR}/libmodelbox-${UNIT_GRAPHCONF}-${UNIT_NAME}.so CACHE INTERNAL "")
